<%@ page import="java.sql.*" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
</head>
<body>
<%
    // 删除数据记录
    // 需要获取参数，用于标记哪条记录
    String id = request.getParameter("id");
    Class.forName("org.mariadb.jdbc.Driver");
        String url = "jdbc:mariadb://10.220.140.102:3366/studb11";
        String user ="stua";
        String password = "zHZUA65r";
        Connection connection = DriverManager.getConnection(url, user, password);
        Statement stmt = connection.createStatement();
        
        // 执行删除操作
        String sql = "DELETE FROM hotel WHERE id=" + id;
        System.out.println("sql=" + sql);
        int r = stmt.executeUpdate(sql);
        System.out.println("影响行数为：" + r);
        // 清理资源
        stmt.close();
        connection.close();
        response.sendRedirect("hotel.jsp");

%>
</body>
</html>
